const koa = require("koa");
const app = new koa();
const data = require("./data/local")
const router = require("koa-router")();
router.get("/top/playlist", async ctx => {
    console.log(ctx.request.query)
    var { offset, limit } = ctx.request.query;
    offset = Number(offset);
    limit = Number(limit)
    var result = data.result;
    if (!offset) {
        offset = 0
    }
    if (!limit) {
        limit = 5
    }
    ctx.body = {
        code: 200,
        data: result.slice(offset, offset + limit),
        total: result.length
    }
})
app.use(router.routes())

app.listen(8080);